<?php

class ContactKoppeling
{
	private $id;
	private $contact_id;
	private $bedrijf_id;
	private $contactpersoon;
	private $begeleider;
	
	private $wsdl;
	private $sugar_client;
	
	/* Constructor */
	public function __construct($arg_wsdl)
	{
		$this->wsdl = $arg_wsdl;
		$this->sugar_client = new nusoapclient($this->wsdl, true);
	}
	
	/* InitData */
	public function setData($arg_contact_id, $arg_bedrijf_id, $arg_contactpersoon, $arg_begeleider)
	{
		$this->id = NULL;
		$this->contact_id = $arg_contact_id;
		$this->bedrijf_id = $arg_bedrijf_id;
		$this->contactpersoon = $arg_contactpersoon;
		$this->begeleider = $arg_begeleider;
	}
	
	/* Set Methoden */
	public function setId($arg_id)
	{
		$this->id = $arg_id;
	}
	
	public function setContact_id($arg_contact_id)
	{
		$this->contact_id = $arg_contact_id;
	}
	
	public function setBedrijf_id($arg_bedrijf_id)
	{
		$this->bedrijf_id = $arg_bedrijf_id;
	}
	
	public function setContactpersoon($arg_contactpersoon)
	{
		$this->contactpersoon = $arg_contactpersoon;
	}
	
	public function setBegeleider($arg_begeleider)
	{
		$this->begeleider = $arg_begeleider;
	}
	
	/* Get Methoden */
	public function getId()
	{
		return $this->id;
	}
	
	public function getContact_id()
	{
		return $this->contact_id;
	}
	
	public function getBedrijf_id()
	{
		return $this->bedrijf_id;
	}
	
	public function getContactpersoon()
	{
		return $this->contactpersoon;
	}
	
	public function getBegeleider()
	{
		return $this->begeleider;
	}
	
	/* Other */
	public function save()
	{
		//Nog aan te passen
		$session_id = $_SESSION['session'];
		$set_entry_params = array(
	    	'session' => $session_id,
	        'module_name' => 'st_Contact_Koppeling',
	        'name_value_list'=>array(
	                           	 	array('name'=>'id','value'=>getId()),
	                           		array('name'=>'st_contact_id_c','value'=>getContact_id()),
									array('name'=>'st_bedrijf_id_c','value'=>getBedrijf_id()),
									array('name'=>'contactpersoon','value'=>getContactpersoon()),
									array('name'=>'begeleider','value'=>getBegeleider()),
									array('name'=>'name','value'=>'stageKoppeling')
	                          		)
	                          );
		
		$result = $this->sugar_client->call('set_entry',$set_entry_params);

		if($result['error']['name']== "No Error")
		{
			$this->id = $result['id'];
			return $result['id'];
		}
		else
		{
			return $result['error']['name'];
		}
	}
}

?>